$(function(){
	$("#chkall").change(function(){
		if ($(this).attr("checked") === "checked") {
			$("input[type='checkbox']").attr("checked", true);
		}
		else{
			$("input[type='checkbox']").attr("checked", false);
		}
	});
    
    $("a[id^='sms_']").click(function(){
		  var msgId = $(this).attr("msgid");
		  $('#msg_'+msgId+'_div').toggle();
        if ($(this).attr("unread") === "Y") {
          
            $.ajax({
                type: "POST",
                url: "/forum/members/smsList/box", //此处是需要访问后台的哪个文件的哪个方法
                data: {
					"msgId":function(){
						return msgId;
					}
				},
                dataType: 'json', //固定的格式，不需要太多关注
                success: function(result){
					
                   if(result===true){
				   	var count=$("#sms_unread").text()-1;
				   	$("#sms_unread").text(count<=0?0:count);
				   	$("#sms_"+msgId).attr("unread","N");
					$("#sms_"+msgId).parent().css("font-weight","normal");
					
				   }
				   else if(result===false){
				   	
				   }
                },
                error: function(result){
                    alert("error" + result);
                }
            });
        }
		
    });
  $('.pagination').jqPagination({
        link_string: '/pages/{page_number}',
        current_page: pageIndex, //设置当前页 默认为1
        max_page: pagesCount, //设置最大页 默认为1
        page_string: '当前第' + pageIndex + '页,共' + pagesCount + '页',
        paged: function(page){
            var href = window.location.href;
            href = href.indexOf("/pages") == -1 ? href : href.substring(0, href.indexOf("/pages"));
            window.location.href = href + "/pages/" + page;
        }
    });
    
});
